package com.rd.student.jiaji.class4.suyan.zrrd.Read;

import java.util.Random;

public class Role {
    String name;
    int boold;
    public Role(){}
    public  Role(String name,int boold){
        this.boold=boold;
        this.name=name;
    }
    public void setName(String name){
        this.name=name;
    }
    public void setBoold(int boold){
        this.boold=boold;
    }
    public String getName(){
        return name;
    }
    public int getBoold(){
        return boold;
    }
    public void attack(Role role){
        Random r=new Random();
        int hurt=r.nextInt(20)+1;
        int remainboold=role.getBoold() - hurt;
        remainboold=remainboold<0 ?0:remainboold;
        role.setBoold(remainboold);
        System.out.println(this.getName()+"举起拳头，打了"+role.getName()+"一下，"+
                "造成了"+hurt+"点伤害，"+role.getName()+"还剩下"+remainboold);

    }
}
